#!/usr/bin/env bash
# Copyright (c) 2022 Presto Labs Pte. Ltd.
# Author: gekim


BINARies_IN_CHECKING=(
"//cc/appcoin2/strategy/rmm:genoi_runner"
"//cc/appcoin2/support:vanilla"
"//cc/appcoin2/support:printer"
"//cc/appcoin2/support:counter"
"//cc/appcoin2/support:serialization_example"
"//cc/appcoin2/support:timestamp"
"//cc/appcoin2/support:approach_target_position"
"//cc/appcoin2/support/feed:fastfeed_converter"
)

BUILD_PARAMETERs=(
'-c opt --cxxopt=-std=c++17'
'-c opt --cxxopt=-std=c++17 --define=dynamic_linking_mode=true'
)

function func_check_binaries {
  for BINARY_IN_CHECKING in ${BINARies_IN_CHECKING[@]}; do
    local EXIT_STATUS=0
    bazel clean --expunge
    echo "bazel build ${BUILD_PARAMETERs[0]} $BINARY_IN_CHECKING"
    bazel build ${BUILD_PARAMETERs[0]} $BINARY_IN_CHECKING || EXIT_STATUS="${?}"
    if [ ! ${EXIT_STATUS} -eq 0 ]; then
      return ${EXIT_STATUS}
    fi

  done
}


func_check_binaries

